<template>
	<view class="container">
		<view class="top">
			<u-tabs :list="list" :is-scroll="false" :current="current" @change="change" lineColor='#8d4a32'  active-color='#8d4a32'></u-tabs>
		</view>
		<view v-if="!Object.keys(order).length"
			class="d-flex w-100 h-100 flex-column just-content-center align-items-center">
			<image src="../../static/logo_shop.jpg" class="drinks-img"></image>
			<view class="tips d-flex flex-column align-items-center font-size-base text-color-assist">
				<view>您还没有点单</view>
				<view>快去犒劳一下自己吧~</view>
			</view>
			<button type="primary" class="drink-btn" size="default" @tap="menu">去点餐</button>
		</view>
		<template v-else>
			<view class="order-box">
				<view class="bg-white">
					<view class="section">
						<!-- store info begin -->
						<list-cell :hover="false">
							<view class="w-100 d-flex align-items-center">
								<view class="d-flex flex-column w-60">
									<view class="w-100 font-size-lg text-color-base text-truncate">草本汤(万达广场店)</view>
								</view>
								<view class="d-flex justify-content-end align-items-center w-40">
									<image @click='refreshOrder' src="../../static/refresh.png" class="refresh"></image>
								</view>
							</view>
						</list-cell>
						<!-- store info end -->
						<list-cell :hover="false" padding="50rpx 30rpx">
							<view class="w-100 d-flex flex-column">
								<!-- steps begin -->
								<view class="d-flex just-content-center">
									<view class="steps d-flex flex-column"
										:class="{'w-80': order.typeCate == 1, 'w-100': order.typeCate == 2}">
										<view class="steps__img-column">
											<view class="steps__img-column-item">
												<image style="width: 40px;height: 40px;" src="../../static/step_1.png"
													v-if="order.status >= 1"></image>
												<image style="width: 40px;height: 40px;filter: grayscale(70%);"
													src="../../static/step_1.png" v-else></image>
											</view>
											<view class="steps__img-column-item" :class="{active: order.status >= 2}">
												<image src="../../static/step_2.png" v-if="order.status >= 2"></image>
												<image src="../../static/step_2.png" style="filter: grayscale(70%);"
													v-else></image>
											</view>

											<view class="steps__img-column-item" :class="{active: order.status >= 4}">
												<image src="../../static/step_3.png" v-if="order.status >= 3"></image>
												<image src="../../static/step_3.png" style="filter: grayscale(70%);"
													v-else></image>
											</view>
										</view>
										<view class="steps__text-column">
											<view class="steps__text-column-item" :class="{active: order.status >= 1}">
												<view class="steps__column-item-line bg-transparent"></view>
												<view class="steps__text-column-item-text">已下单</view>
												<view class="steps__column-item-line"></view>
											</view>
											<view class="steps__text-column-item" :class="{active: order.status >= 2}">
												<view class="steps__column-item-line"></view>
												<view class="steps__text-column-item-text">制作中</view>
												<view class="steps__column-item-line"></view>
											</view>

											<view class="steps__text-column-item" :class="{active: order.status >= 4}">
												<view class="steps__column-item-line"></view>
												<view class="steps__text-column-item-text">配送中</view>
												<view class="steps__column-item-line bg-transparent"></view>
											</view>
										</view>
									</view>
								</view>

								<view class="w-100 d-flex flex-column position-relative mt-30"
									style="margin-bottom: -40rpx;">
									<view class="w-100 d-flex align-items-center mb-40"
										v-for="(good, index) in goodsList" :key="index">
										<view class="d-flex flex-column w-60 overflow-hidden">
											<view class="font-size-lg text-color-base mb-10 text-truncate">
												{{ good.name }}</view>
											<view class="font-size-sm text-color-assist text-truncate">
												{{ good.props_text }}</view>
										</view>
										<view class="d-flex w-40 align-items-center justify-content-between pl-30">
											<view class="font-size-base text-color-base">x{{ good.number }}</view>
											<view class="font-size-base text-color-base font-weight-bold">
												￥{{ good.price }}</view>
										</view>
									</view>
								</view>
								<!-- goods end -->
							</view>
						</list-cell>
					</view>
					<view class="section">
						<!-- payment and amount begin -->
						<list-cell :hover="false" padding="50rpx 30rpx">
							<view class="w-100 d-flex flex-column">
								<view class="pay-cell">
									<view>支付方式</view>
									<view class="font-weight-bold">{{ order.pay_mode }}</view>
								</view>
								<view class="pay-cell">
									<view>金额总计</view>
									<view class="font-weight-bold">￥{{ order.amount }}</view>
								</view>
							</view>
						</list-cell>
						<!-- payment and amount end -->
					</view>
					<!-- order info begin -->
					<list-cell :hover="false" padding="50rpx 30rpx">
						<view class="w-100 d-flex flex-column">
							<view class="pay-cell">
								<view>下单时间</view>
								<view class="font-weight-bold">2023-09-19 14:45:51</view>
							</view>
							<view class="pay-cell">
								<view>下单门店</view>
								<view class="font-weight-bold">草本汤(万达广场店)</view>
							</view>
							<view class="pay-cell">
								<view>支付方式</view>
								<view class="font-weight-bold">{{ order.pay_mode }}</view>
							</view>
							<view class="pay-cell">
								<view>订单号</view>
								<view class="font-weight-bold">{{ order.order_no }}</view>
							</view>
						</view>
					</list-cell>
					<!-- order info end -->


				</view>
			</view>
			<view class="zw"></view>
		</template>
	</view>
</template>

<script>
	import listCell from '@/components/list-cell/list-cell'
	import {
		mapState
	} from 'vuex'

	export default {
		components: {
			listCell
		},
		data() {
			return {
				goodsList: [],
				list: [{
					name: '当前订单'
				}, {
					name: '历史订单'
				}, ],
				current: 0
			}
		},
		computed: {
			...mapState(['order'])
		},
		onLoad() {
			this.goodsList = uni.getStorageSync('orderInfo')
		},
		methods: {
			//tab切换
			change(index) {
				this.current = index;
			},
			//更新订单状态
			refreshOrder() {

			},
			orders() {

				uni.navigateTo({
					url: '/pages/orders/orders'
				})
			},
			menu() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	/* #ifdef H5 */
	page {
		min-height: 100%;
		// background-color: $bg-color;
		background: #f5f2f0 !important;
	}

	/* #endif */
	.order-box {
		padding: 20rpx;
		/* #ifdef H5 */
		margin-bottom: 100rpx;
		/* #endif */
	}

	.refresh {
		height: 28px;
		width: 28px;
	}

	.drinks-img {
		width: 260rpx;
		height: 260rpx;
	}

	.tips {
		margin: 60rpx 0 80rpx;
		line-height: 48rpx;
	}

	.drink-btn {
		width: 320rpx;
		border-radius: 50rem !important;
		margin-bottom: 40rpx;
		font-size: $font-size-base;
		line-height: 3.0;
	}

	@mixin arch {
		content: "";
		position: absolute;
		background: rgba(245, 242, 240, 1) !important;
		width: 30rpx;
		height: 30rpx;
		bottom: -15rpx;
		z-index: 10;
		border-radius: 100%;
	}

	.section {
		position: relative;

		&::before {
			@include arch;
			left: -15rpx;
		}

		&::after {
			@include arch;
			right: -15rpx;
		}
	}
	.zw{
		height: 50px;width: 100%;
	}
	.pay-cell {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: $font-size-base;
		color: $text-color-base;
		margin-bottom: 40rpx;

		&:nth-last-child(1) {
			margin-bottom: 0;
		}
	}

	.sort-num {
		font-size: 64rpx;
		font-weight: bold;
		color: $text-color-base;
		line-height: 2;
	}

	.steps__img-column {
		display: flex;
		margin: 30rpx 0;

		.steps__img-column-item {
			flex: 1;
			display: flex;
			align-items: center;
			justify-content: center;

			image {
				width: 80rpx;
				height: 80rpx;
			}
		}
	}

	.steps__text-column {
		display: flex;
		margin-bottom: 40rpx;

		.steps__text-column-item {
			flex: 1;
			display: inline-flex;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: $font-size-base;
			color: $text-color-assist;

			&.active {
				color: $text-color-base;
				font-weight: bold;

				.steps__column-item-line {
					background-color: $text-color-base;
				}
			}

			.steps__column-item-line {
				flex: 1;
				height: 2rpx;
				background-color: #919293;
				transform: scaleY(0.5);
			}

			.steps__text-column-item-text {
				margin: 0 8px;

			}
		}
	}
</style>